import BaseApi from "./BaseApi";

const userConroller = "/user";
const parkConroller = "/park";
const truckSpaceConroller = "/truckSpace";

export default {

    /**
     * 获取设备序列号列表
     */
    getImeiList(condition) {
        return this.requestPost(parkConroller, "/getImeiList", condition);
    },

    /**
     * 获取停车点列表S
     * @returns {*|Promise|Promise<any>|Window.Promise}
     */
    getParkList(condition) {
        return this.requestPost(parkConroller, "/getAllPark", condition);
    },

    /**
     * 根据类型获取停车点列表
     * @returns {*|Promise|Promise<any>|Window.Promise}
     */
    getParkByType(value) {
        let type = {"type":value}
        return this.requestPost(parkConroller, "/getParkByType", type);
    },

    /**
     * 获取管理员列表
     * @returns
     */
    getLeaderList(){
        return this.requestPost(userConroller, "/getAllLeader");
    },

    /**
     * 获取停车位列表
     * @param condition
     * @returns {*|Promise|Promise<any>|Window.Promise}
     */
    getTruckSpaceList(condition) {
        let url = "/list";
        return this.requestGet(truckSpaceConroller, url, condition);
    },

    /*请求封装*/
    requestPost(controller, url, condition) {
        let newUrl = controller + url;
        return BaseApi.requestPost(newUrl, condition);

    },
    requestGet(controller, url, condition) {
        let newUrl = controller + url;
        return BaseApi.requestGet(newUrl, condition);
    }
}
